<?php
class AdminVisitor {
	public static function getAdminGrant() {
		$adminInfo = AdminSession::getAdminSessionInfo ();
		require_once APP_LIB_PATH . 'adminLib.php';
		$adminlib = new AdminLib ();
		$adminInfo = $adminlib->getByAdminName ( $adminInfo ['AdminName'] );
		$grantInfo = json_decode ( $adminInfo ['AdminGrant'],TRUE );
		return $grantInfo;
	}
	
	public static function setAdminSession() {
	
	}
	
	
	
	public static function checkGrant($key,$isNeedGradeId=TRUE, $isThrowException = TRUE) {
		$adminInfo = AdminSession::getAdminSessionInfo ();
		if($adminInfo ['AdminName'] =='admin'){
			return true;
		}
		require_once APP_LIB_PATH . 'adminLib.php';
		$adminLib = new AdminLib ();
		try {
			return $adminLib->checkGrand ( $key,$isNeedGradeId );
		} catch ( Exception $e ) {
			if ($isThrowException) {
				BaseAction::adminError ( $e->getMessage () );
			} else {
				return FALSE;
			}
		}
	}
	
	public static function getAdminInfo() {
	
	}
	public static function checkLogin() {
		if (AdminSession::getAdminSessionInfo ()) {
			return TRUE;
		}
		BaseAction::adminError ( "对不起，请不要非法操作" );
	}
	
	public static function getIp() {
		require_once SOURCE_EXT_PATH . 'library/IpLib.php';
		return IpLib::retrieveClientIp ();
	}
	public static function getDateTime() {
		return date ( 'Y-m-d H:i:s' );
	}
	public static function isHaveGrant($grandName) {
		print_r ( json_decode ( AdminSession::getAdminSessionInfo ()->GrantIdentifier ) );
	}
}

?>